Skip to content

Conversation

aaronseq12
Copy link

Description:

This change fixes a ValidationError that occurred when using init_chat_model with model_provider="huggingface".

The previous implementation incorrectly passed all keyword arguments directly to the ChatHuggingFace constructor, which expects an llm object rather than a model_id. This caused a Pydantic error when arguments like task were provided.

The fix updates the logic to first correctly instantiate a HuggingFacePipeline object using the from_model_id class method, which properly handles arguments like task. This initialized pipeline object is then passed to the ChatHuggingFace wrapper, resolving the issue.

A unit test has been added to verify the fix and prevent regressions.

Closes #28226

Issue:

Fixes #28226

Dependencies:

None

Copy link

vercel bot commented Sep 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
langchain Ignored Ignored Preview Oct 1, 2025 3:13pm

@github-actions github-actions bot added the langchain Related to the package `langchain` label Sep 30, 2025
Copy link
Collaborator

@eyurtsev eyurtsev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aaronseq12 thanks for the contribution -- there seem to be a lot of typos in this PR, do you want to try and resolve?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
langchain Related to the package `langchain`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

init_chat_model doesn't work with huggingface models
3 participants